import * as request from "@/utils/request"

const API_PREFIX = "/Role"

/**
 * 创建角色
 */
export function roleCreate(params: RoleCreateRequest) {
  return request.post<boolean>({
    url: API_PREFIX + "/Create",
    data: params
  })
}

/**
 * 删除角色
 */
export function roleDelete(params: DeleteRequest) {
  return request.get<boolean>({
    url: API_PREFIX + "/Delete",
    params
  })
}

/**
 * 编辑角色
 */
export function roleEdit(params: RoleEditRequest) {
  return request.post<boolean>({
    url: API_PREFIX + "/Edit",
    data: params
  })
}

/**
 * 根据 ID 获取角色
 */
export function getRoleById(params: RoleGetByIdRequest) {
  return request.get<RoleResponse>({
    url: API_PREFIX + "/Get",
    params
  })
}

/**
 * 获取所有角色
 */
export function getAllRole() {
  return request.get<RoleResponse[]>({
    url: API_PREFIX + "/GetAll"
  })
}

/**
 * 分页获取所有角色
 */
export function getRoleByPage(params: RoleQueryRequest) {
  return request.get<PageResponse<RoleResponse>>({
    url: API_PREFIX + "/GetPage",
    params
  })
}

export function setRoleMenu(params: RoleSetMenuRequest) {
  return request.post<boolean>({
    url: API_PREFIX + "/SetRoleMenu",
    data: params
  })
}
